<template>

</template>

<script setup lang="ts">
import { ref } from 'vue';

const token = ref('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOjAsInJuU3RyIjoiQUFPVXh6NjJNV1kwaHVsNUlLb053T2JTRGRvTW1sdHciLCJjbGllbnRJZCI6IjE5NWRhOWZjY2U1NzQ4NTJiODUwMDY4NzcxY2RlMDM0IiwidGVuYW50SWQiOjAsInVzZXJJZCI6MH0.gRPBnwIUMeaC0vrRvEUIfm1WE5X1w1QYSHF_3OD5QnY')
const count = ref(0);
const ws = new WebSocket('ws://localhost:9991/api/admin/socket', [token.value])
console.log(ws);
console.log(`正在进行第 ${count.value} 次尝试连接WS服务端...`);
ws.onopen = () => {
    console.log(`成功建立与WS服务器的连接`);
}

ws.onmessage = (e) => {
    console.log(`接收到服务端的消息：${e.data}`);
}

ws.onclose = () => {
    console.log(`与WS服务器的连接已关闭`);
}

ws.onerror = () => {
    console.log(`与WS服务器的连接发生错误`);
}

</script>

<style lang="less" scoped>

</style>